package yygh.hosp.Controller;

import yygh.hospital.model.hosp.Schedule;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yygh.common.result.Result;
import yygh.hosp.Service.ScheduleService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    //排班接口1：排班规则展示，根据医院编号和科室编号，查询排班规则数据展示。
    //查询对应科室的排班
    @ApiOperation(value = "根据医院编号和科室编号，查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {
        //以一个map集合的方式返回
        Map<String,Object> map= scheduleService.getRuleSchedule(page,limit,hoscode,depcode);
        return  Result.ok(map);
    }


    //排班接口2：排版信息详解，根据医院编号、科室编号和排版日期查询详细的排班信息。
    @ApiOperation(value = "根据医院编号、科室编号和排版日期查询详细的排班信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate){

    List<Schedule> schedules=scheduleService.getScheduleDetail(hoscode,depcode,workDate) ;
        return  Result.ok(schedules);
    }

}
